package com.ymatou.iapi.livebuyer.testcase;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.GenLiveMessageBean;
import com.ymatou.iapi.livebuyer.service.GenLiveMessageCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 查询直播聊天记录 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GenLiveMessage {
	private static GenLiveMessageBean GenLiveMessageBean;
	private static GenLiveMessageCall GenLiveMessageCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询直播聊天记录");
	}

	@Before
	public void caseUp() {
		GenLiveMessageBean = new GenLiveMessageBean();
		GenLiveMessageCall = new GenLiveMessageCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GenLiveMessageCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GenLiveMessage_001() {
		Logger.start(true, "查询直播聊天记录成功");
		try {
			Long msgTime = Long.valueOf(YMTDateUtil.getSysTime("yyyyMMddHH")) - 2;
			GenLiveMessageBean.setMsgTime(msgTime.toString());
			GenLiveMessageCall.setData(GenLiveMessageBean);
			GenLiveMessageCall.callService();
			Logger.verifyEquals("ok", GenLiveMessageCall.getReturnData(), "验证code");
			// TODO 验证MessageTask 详细记录在 logging.db.ymatou.com - logging -
			// logginguser1）livemessage
			// 可能出现没有文件的情况 需要等待
			LiveRoomWapper liveRoomWapper = new LiveRoomWapper();
			Map m = liveRoomWapper.selectMessagetaskByMsgtime(GenLiveMessageBean.getMsgTime());
			if (m != null) {
				Logger.debug(m);
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}